package com.ymatou.app.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.app.parameter.LiveInfoBean;
import com.ymatou.app.service.LiveInfoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.SellerCallService;

public class Ts_LiveInfo {
	
	private static LiveInfoBean liveInfoBean = null;
	private static LiveInfoCall liveInfoCall = null;
	private static SellerCallService sellerCallService = null;
	
	private static int activityId = 0;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取直播详情接口");
		
		sellerCallService = new SellerCallService("ukseller", "aabbcc");
	}

	@Before
	public void caseUp() {
		liveInfoBean = new LiveInfoBean();
		liveInfoCall = new LiveInfoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(liveInfoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetLiveInfo_001() {
		Logger.start(true,"验证直播id是否正确");
		try {
			Logger.comment("创建直播");
			sellerCallService.createActivity();
			
			activityId = sellerCallService.getActivityInProgress();
			
			Logger.comment("添加商品");
			sellerCallService.createProduct(activityId);
			
			Logger.comment("直播验证");
			liveInfoBean.setLiveid(activityId);
			
			liveInfoCall.setData(liveInfoBean);
			liveInfoCall.callService();			
			Logger.comment("activityCall send:" + liveInfoCall.getEntityString());
			Logger.comment("activityCall response:" + liveInfoCall.getReturnData());
			
			Logger.verifyEquals(activityId, liveInfoCall.getLiveInfo().get("id"), "验证直播id是否正确");		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetLiveInfo_002() {
		Logger.start(true,"验证直播正在进行");
		try {
			Logger.comment("前置条件准备");

			liveInfoBean.setLiveid(activityId);
			
			liveInfoCall.setData(liveInfoBean);
			liveInfoCall.callService();			
			Logger.comment("activityCall send:" + liveInfoCall.getEntityString());
			Logger.comment("activityCall response:" + liveInfoCall.getReturnData());
			
			Logger.verifyEquals(1, liveInfoCall.getLiveInfo().get("state"), "验证直播正在进行");		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
